<?php
/**
 * 
 * 
 * @version $Id: QQ.php 5 2012-08-30 04:12:41Z linsir123 $
 */
class weiboQQ implements WeiboBase
{
	/**
	 * @var 配置
	 */
	public $conf;
	
	/**
	 * 构造函数
	 */
	public function __construct()
	{
		session_start();
		
		///
		$this->conf = App::O('app.qq');
		
		///
		App::V('weiboQQ');
		OpenSDK_Tencent_Weibo::init($this->conf['key'][0], $this->conf['key'][1]);
	}
	
	/**
	 * 取得授权地址
	 */
	public function getOauthUrl()
	{
		$callback = lpUrl::__($this->conf['callback'], null, true);
		$requestToken = OpenSDK_Tencent_Weibo::getRequestToken($callback);
		$url = OpenSDK_Tencent_Weibo::getAuthorizeURL($requestToken);
		///
		return $url;
	}
	
	/**
	 * 回调操作
	 */
	public function doCallback()
	{
		if (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) 
			return OpenSDK_Tencent_Weibo::getAccessToken($_GET['oauth_verifier']);
			
		///
		return false;
	}
	
	/**
	 * 验证是否登录
	 */
	public function isLogin()
	{
		return isset($_SESSION['tencent_oauth_name']);
	}
	
	/**
	 * 取得当前登录的用户
	 */
	public function getUser()
	{
		return OpenSDK_Tencent_Weibo::call('user/info');
	}
}
